import request from '@/utils/request'
import { CHECC_API_BASE_DATA } from '@/constants/proxy'

// 获取桥梁列表
export function requestBridgeList(params:any,data: any): Promise<any> {
  return request({
    url: CHECC_API_BASE_DATA + `/bd-bridge-in/page`,
    method: 'post',
    params,
    data:data,
  })
}

// 保存桥梁信息
export function saveBridge(data: any): Promise<any> {
  return request({
    url: CHECC_API_BASE_DATA + `/bd-bridge-in`,
    method: 'post',
    data
  })
}

// 删除桥梁信息
export function delBridge(data: any): Promise<any> {
  return request({
    url: CHECC_API_BASE_DATA + `/bd-bridge-in`,
    method: 'delete',
    data
  })
}

// 桥梁锁定/解锁
export function bridgeLock(data: any): Promise<any> {
  return request({
    url: CHECC_API_BASE_DATA + `/bd-bridge-in/bridgeLock`,
    method: 'POST',
    data
  })
}

// 更新桥梁信息
export function updateBridge(data: any): Promise<any> {
  return request({
    url: CHECC_API_BASE_DATA + `/bd-bridge-in`,
    method: 'PUT',
    data
  })
}
// 通过id 获取数据
export function obtainBridge(data: any): Promise<any> {
  return request({
    url: CHECC_API_BASE_DATA + `/bd-bridge-in/${data}`,
    method: 'get',
  })
}


export function requestPartsTree(params: any): Promise<any>{
  return request({
    url: CHECC_API_BASE_DATA + `/bd-bridge-in/getParts`,
    method: 'get',
    params
  })
}


export function requestComponentTree(params: any): Promise<any>{
  return request({
    url: CHECC_API_BASE_DATA + `/bd-bridge-in/getComponents`,
    method: 'get',
    params
  })
}

// 导出
export function exportBridgeRecordsRequest(): Promise<any>{
  return request({
    url: CHECC_API_BASE_DATA + `/bd-bridge-in/export`,
    method: 'post',
    data: {}
  })
}

/* 子表
/* 最近技术状况评定 */
export function getBridgeInEvaluation(data): Promise<any> {
  return request({
    url: CHECC_API_BASE_DATA + `/bd-bridge-in-evaluation/page`,
    method: 'post',
    data: data.data || {},
    params: data.params
  })
}

export function addBridgeInEvaluation(data: any): Promise<any> {
  return request({
    url: CHECC_API_BASE_DATA + `/bd-bridge-in-evaluation`,
    method: 'post',
    data
  })
}

export function updateBridgeInEvaluation(data: any): Promise<any> {
  return request({
    url: CHECC_API_BASE_DATA + `/bd-bridge-in-evaluation`,
    method: 'put',
    data
  })
}

export function delBridgeInEvaluation(data: any): Promise<any> {
  return request({
    url: CHECC_API_BASE_DATA + `/bd-bridge-in-evaluation`,
    method: 'delete',
    data
  })
}

/* 修建工程记录 */
export function getBridgeInConstruction(data): Promise<any> {
  return request({
    url: CHECC_API_BASE_DATA + `/bd-bridge-in-construction/page`,
    method: 'post',
    data: data.data || {},
    params: data.params
  })
}

export function addBridgeInConstruction(data: any): Promise<any> {
  return request({
    url: CHECC_API_BASE_DATA + `/bd-bridge-in-construction`,
    method: 'post',
    data
  })
}

export function updateBridgeInConstruction(data: any): Promise<any> {
  return request({
    url: CHECC_API_BASE_DATA + `/bd-bridge-in-construction`,
    method: 'put',
    data
  })
}

export function delBridgeInConstruction(data: any): Promise<any> {
  return request({
    url: CHECC_API_BASE_DATA + `/bd-bridge-in-construction`,
    method: 'delete',
    data
  })
}

/* 构件信息 */
export function getBridgeInComponent(data): Promise<any> {
  return request({
    url: CHECC_API_BASE_DATA + `/bd-bridge-component/page`,
    method: 'post',
    data: data.data || {},
    params: data.params
  })
}

export function addBridgeInComponent(data: any): Promise<any> {
  return request({
    url: CHECC_API_BASE_DATA + `/bd-bridge-component`,
    method: 'post',
    data
  })
}

export function updateBridgeInComponent(data: any): Promise<any> {
  return request({
    url: CHECC_API_BASE_DATA + `/bd-bridge-component`,
    method: 'put',
    data
  })
}

export function delBridgeInComponent(data: any): Promise<any> {
  return request({
    url: CHECC_API_BASE_DATA + `/bd-bridge-component`,
    method: 'delete',
    data
  })
}

export function getBridgePosition(data: Record<string, string>): Promise<any>{
  return request({
    url: CHECC_API_BASE_DATA + `/bd-bridge-component-library/getBridgePosition`,
    method: 'post',
    data
  })
}

export function getBridgeParts(bridgePartCode){
  return request({
    url: CHECC_API_BASE_DATA + `/bd-bridge-component-library/getBridgeParts/${bridgePartCode}`,
    method: 'get',
  })
}

// 桥梁概览信息
export function bridgeRecordsRequest(params:any,data: any): Promise<any> {
  return request({
    url: CHECC_API_BASE_DATA + `/bd-bridge-in/overview`,
    method: 'post',
    params,
    data:data,
  })
}